use "/Users/yooneuikim/Dropbox/RIO_KMZ/RIO_KMZ.dta", clear
xtset ccode year

*Table 1 Descriptive Statistics
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
sum UPR UPR_cat5 share_UPR share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg if e(sample)

*Table 2 Main Results
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m1

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m2

reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m3

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m4

esttab m1 m2 m3 m4 using table2.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		stats(N ll,fmt("%9.0fc")) ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 
		
*Tables 3 & 4
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year

margins, at (f_elite = (0 0.269 0.829)) atmeans predict(n) /* not in the range so bottom value set to zero*/

margins, at (w_parliament = (0.101 0.22 0.339)) atmeans predict(n)

margins, at (lnngo = (0.182 1.451 2.72)) atmeans predict(n)

margins, at (UNHRC_Served = (0 1)) atmeans predict(n)

margins, at (IO_membership_count = (51.89 69.152 86.414)) atmeans predict(n)

margins, at (reservationsum = (0 0.732 2.186)) atmeans predict(n) /* not in the range so bottom value set to zero*/

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
margins, at (f_elite = (0 0.269 0.829)) atmeans predict(n) /* not in the range so bottom value set to zero*/

margins, at (w_parliament = (0.101 0.22 0.339)) atmeans predict(n)

margins, at (lnngo = (0.182 1.451 2.72)) atmeans predict(n)

margins, at (UNHRC_Served = (0 1)) atmeans predict(n)

margins, at (IO_membership_count = (51.89 69.152 86.414)) atmeans predict(n)

margins, at (reservationsum = (0 0.732 2.186)) atmeans predict(n) /* not in the range so bottom value set to zero*/

*Table 5 Cosine Similarity with Canada
reg sim1 f_elite v2lgfemleg lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper dem v2clgencl mean_gii_sur region_avrg i.year
estimate store m5
esttab m5 using table_5.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 

*APPENDIX MODELS		
* CORRELATION MATRIX Table A1
corr UPR UPR_cat5 share_UPR share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg

*Joint t-test for domestic variables Table A2
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test f_elite w_parliament lnngo

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test f_elite w_parliament lnngo

reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test f_elite w_parliament lnngo

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test f_elite w_parliament lnngo

*Joint t-test for international variables Table A2
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test UNHRC_Served IO_membership_count reservationsum

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test UNHRC_Served IO_membership_count reservationsum

reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test UNHRC_Served IO_membership_count reservationsum

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
test UNHRC_Served IO_membership_count reservationsum

*Table A3 lagged IVs
nbreg UPR L.f_elite L.w_parliament L.lnngo L.UNHRC_Served L.IO_membership_count L.reservationsum L.ln2gdper L.v2x_polyarchy L.v2clgencl L.mean_gii_sur L.region_avrg i.year
estimates store m6

nbreg UPR_cat5 L.f_elite L.w_parliament L.lnngo L.UNHRC_Served L.IO_membership_count L.reservationsum L.ln2gdper L.v2x_polyarchy L.v2clgencl L.mean_gii_sur L.region_avrg i.year
estimates store m7

reg share_UPR L.f_elite L.w_parliament L.lnngo L.UNHRC_Served L.IO_membership_count L.reservationsum L.ln2gdper L.v2x_polyarchy L.v2clgencl L.mean_gii_sur L.region_avrg i.year
estimates store m8

reg share_UPR5 L.f_elite L.w_parliament L.lnngo L.UNHRC_Served L.IO_membership_count L.reservationsum L.ln2gdper L.v2x_polyarchy L.v2clgencl L.mean_gii_sur L.region_avrg i.year
estimates store m9

esttab m6 m7 m8 m9 using tablea3.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 
		
*Table A4: 3SLS, seemingly unrelated regression 

*domestic variables with share cat 5
reg3 (share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year) (f_elite = share_UPR5 lnpop ) (w_parliament = share_UPR5 milper) (lnngo = share_UPR5 wproperty), sure
estimates store m10

*international variables with share cat 5
reg3 (share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year) (UNHRC_Served = share_UPR5 lnpop) (IO_membership_count = share_UPR5 milper) (reservationsum = share_UPR5 wproperty), sure
estimates store m11

esttab m10 m11 using tablea4.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 
		
*Table A5
*Comparing groups above and below the mean cosine similarity with Canada
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
*mean is 0.2899747
sum f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg if sim1>=0.2899747 & e(sample)
sum f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg if sim1<0.2899747 & e(sample)

*Code for difference of means tests comparing states above and below median in cosine similarty with Canada's UPR recommendations
gen group1=1 if sim1<0.2899747 & e(sample)
sum group1
gen group2=1 if sim1>0.2899747 & e(sample)
sum group2
gen group3=.
recode group3 .=1 if group2==1
recode group3 .=0 if group1==1
tab group3
ttest f_elite, by(group3)
ttest w_parliament , by(group3)
ttest lnngo , by(group3)
ttest UNHRC_Served, by(group3)
ttest IO_membership_count , by(group3)
ttest reservationsum, by(group3)
gen group4=group3
recode group4 0=2 1=0
recode group4 2=1
tab group4
ttest f_elite, by(group4)
ttest UPR, by(UNHRC_Served)
ttest UPR_cat5, by(UNHRC_Served)
ttest UPR_cat5, by(UNHRC_Served)
ttest share_UPR, by(UNHRC_Served)
ttest share_UPR5, by(UNHRC_Served)

*Table A6 with Zvogbo reservtion measure
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservation ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m22

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservation ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m23

reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservation ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m24

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservation ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year
estimates store m25

esttab m22 m23 m24 m25 using tablea6.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		stats(N ll,fmt("%9.0fc")) ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 

*Table A7, models for years before 2015
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year if year<2015
estimates store m26

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year if year<2015
estimates store m27

reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year if year<2015
estimates store m28

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg i.year if year<2015
estimates store m29

esttab m26 m27 m28 m29 using tablea7.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		stats(N ll,fmt("%9.0fc")) ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 

*Table A8 for split sample by democracy
*At or above V-Dem polarchy median
*Note that I removed the democracy variable from these analyses. 

*Table A8a: Negative Binomial Models for Democracies and Non-Democracies
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy >= 0.534
estimates store m14

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy >= 0.534
estimates store m15

*At or above V-Dem polarchy median
nbreg UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy < 0.534
estimates store m16

nbreg UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy < 0.534
estimates store m17

esttab m14 m15 m16 m17 using tablea8a.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 

*Table A8b: Regression Models for Democracies and Non-Democracies
*Below V-Dem polarchy median
reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy >= 0.534
estimates store m18

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy >= 0.534
estimates store m19

*Below V-Dem polarchy median
reg share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy < 0.534
estimates store m20

reg share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2clgencl mean_gii_sur region_avrg i.year if v2x_polyarchy < 0.534
estimates store m21

esttab m18 m19 m20 m21 using tablea8b.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 
		
*Table A9: results using lagged DV instead of year fixed effects
nbreg UPR L.UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg 
estimates store m1

nbreg UPR_cat5 L.UPR_cat5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg 
estimates store m2

reg share_UPR L.share_UPR f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg 
estimates store m3

reg share_UPR5 L.share_UPR5 f_elite w_parliament lnngo UNHRC_Served IO_membership_count reservationsum ln2gdper v2x_polyarchy v2clgencl mean_gii_sur region_avrg 
estimates store m4

esttab m1 m2 m3 m4 using tablea9.rtf, b(3) compress ///
		 se label replace cells(b(fmt(3) star) ///
		se(par)) starlevels(* .10 ** .05)  ///
		stats(N ll,fmt("%9.0fc")) ///
		varwidth(30) nonumbers collabels(, none) eqlabels(, none) 

*Difference of means tests reported in footnote 9
oneway UPR UNHRC_Served, tabulate
oneway UPR_cat5 UNHRC_Served, tabulate
oneway share_UPR UNHRC_Served, tabulate
oneway share_UPR5 UNHRC_Served, tabulate

*Difference of means tests reported on page 19 for 6 most gender-promoting UPR states
gen highuprstate=0
recode highuprstate 0=1 if ccode==20
recode highuprstate 0=1 if ccode==210
recode highuprstate 0=1 if ccode==220
recode highuprstate 0=1 if ccode==230
recode highuprstate 0=1 if ccode==349
recode highuprstate 0=1 if ccode==395

oneway UNHRC_Served highuprstate, tabulate
oneway IO_membership_count highuprstate, tabulate
oneway reservationsum highuprstate, tabulate
oneway f_elite highuprstate, tabulate
oneway w_parliament highuprstate, tabulate
oneway lnngo highuprstate, tabulate



